Mule : Http Provider
This page last changed on Aug 20, 2006 by aperepel.
The http connector can be used to send and receive mule events over http. It has a https connector used for http communication over ssl. The javadoc for this transport provider can be found here. And the Source Xref can be found here Http Connector Properties
Https Connector PropertiesIn addition to the above properties for the https connector you can also configure server and client certificate information. You will need to use the org.mule.providers.http.HttpsConnector in you Xml config file when configuring the connector.
EndpointsHttp endpoints are described as socket-based endpoints in the form of - http://localhost:1234 To use https instead you need to change the endpoint URI protocol and set the necessary certificate information listed above - https://localhost:1234 Unlike http endpoints you can't use https endpoints without having a https connector declared in your configuration. The https connector class is org.mule.providers.http.HttpsConnector. Endpoint PropertiesAny Http Response Header values can be added as endpoint properties. The following is a short list of some of the most usefull properties.
The following is a short example, depicting how to set these properties on the endpoint. <endpoint address="http://localhost:8080/mine" synchronous="true"> <properties> <property name="Content-Type" value="text/html"/> <property name="Location" value="http://mule.codehaus.org/"/> <property name="http.status" value="307"/> </properties> </endpoint> In this case, the type of the payload is that of text/html & we are also instructing the client to redirect ('http.status' being set to 307 = temporary redirection) to "http://mule.codehause.org". SecurityIf you want to secure requests to your Http endpoint the http connector supports Http Basic/Digest authentication methods (as well as the Mule generic header authentication). If you want to configure Http Basic you need to configure a Security Endpoint Filter on a http endpoint. <endpoint address="http://localhost:4567"> <security-filter className="org.mule.extras.acegi.filters.http.HttpBasicAuthenticationFilter"> <properties> <property name="realm" value="mule-realm"/> </properties> </security-filter> </endpoint> You'll need to configure a security manager on the Mule instance for this security filter to authenticate against. For information about security configuration options and examples see Mule Security. For general information about Endpoint configuration see Mule Endpoints. Sending CredentialsIf you want to make a Http request that requires authentication, you can set the credentials on the endpoint - http://user:[email protected]/secure Polling Http ServicesThe Http transport supports Polling a Http URL, this is useful to grab periodic data from a page that changes of to invoke a REST service such as polling an Amazon Queue. To configure the Http Polling receiver you must include a HttpConnector configuration in your MuleXml. <connector name="pollingHttp" className="org.mule.providers.http.HttpConnector"> <properties> <map name="serviceOverrides"> <property name="message.receiver" value=" org.mule.providers.http.PollingHttpMessageReceiver"/> </map> </properties> </connector> To use the connectore in you endpoints use - http://anothercompany.com/services?connector=pollingHttp&pollingFrequency=30000 The equivilent explict enpoint configuration would look like - <endpoint address="http://anothercompany.com/services" connector="pollingHttp"> <properties> <property name="pollingFrequency" value="30000"/> </properties> </endpoint> TransformersThe following transformers are used by default for this connector unless a transformer is explicitly set on the provider.
TODO Handling HTTP Content-Type and EncodingSending HTTP (since Mule 1.3 RC2)This is both for sending POST request bodies as a client and when returning a response body: If we have a String, char[], Reader or similar:
For binary content, encoding is not relevant. Content-Type is set as follows:
Receiving HTTP (since Mule 1.3 RC2)This is both for receiving POST requests (as server) and when getting the response bodies as a client: If Content-Type header is received:
If the Content-Type header is not present:
|
Document generated by Confluence on Nov 27, 2006 10:27 |